﻿/*----------------------------------------------------------------
//  <copyright file="AuditOperationController.cs" company="MicroCloud@151504200868">
//      Copyright © 2020-2024 MicroCloud Corporation, All rights reserved.
//  </copyright>
//  <site>https://gitee.com/chenmm123/microclouds</site>
//  <last-editor>cmm</last-editor>
//  <last-date>2023-11-22 14:58</last-date>
//----------------------------------------------------------------*/

namespace MicroCloud.Api.Audit.Areas.Admin.Controllers.Audit
{
    #region "操作审计"
    /// <summary>
    /// 操作审计
    /// </summary>
    [Description("操作审计")]
    [ModuleInfo(Code = "AuditOperation", Name = "操作审计", OrderNo = 2, Position = "Audit", PositionName = "审计模块")]
    public class AuditOperationController : AdminControllerBase
    {
        #region "属性"
        #region "获取 审计模块业务契约"
        /// <summary>
        /// 获取 审计模块业务契约
        /// </summary>
        protected IAuditContract AuditContract => ServiceProvider.GetService<IAuditContract>();
        #endregion

        #endregion

        #region "Action方法"
        #region "读取操作审计信息"
        /// <summary>
        /// 读取操作审计信息
        /// </summary>
        /// <param name="request">页数据请求</param>
        /// <returns>操作审计信息的页数据</returns>
        [HttpPost]
        [ModuleInfo]
        [Description("读取")]
        public virtual PageData<AuditOperationOutputDto> Read(PageRequest request)
        {
            Check.NotNull(request, nameof(request));
            IFunction function = this.GetExecuteFunction();

            Expression<Func<AuditOperation, bool>> predicate = FilterService.GetExpression<AuditOperation>(request.FilterGroup);
            request.AddDefaultSortCondition(new SortCondition("CreatedTime", ListSortDirection.Descending));

            var page = CacheService.ToPageCache<AuditOperation, AuditOperationOutputDto>(AuditContract.AuditOperations, predicate, request.PageCondition, function);
            return page.ToPageData();
        }
        #endregion

        #endregion

    }
    #endregion

}
